<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            首页
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="../css/x-admin.css" media="all">
        <link rel="stylesheet" href="../css/pag.css" media="all">
        <link rel="stylesheet" href="../css/pag.css" media="all">
        <link rel="stylesheet" href="../css/sbgl.css" media="all" type="text/css">

    </head>
    <body>
        <div class="x-nav">
                <h2>
					 设备管理维护 <img src="../images/user1.png" alt="" height="20px" width="20px" /><small>
						- 您可以通过搜索或者其他的筛选项对设备的信息进行修改、删除等管理操作。^_^</small>
				</h2>
        </div>

        <div class="x_content">
            <form method="post" action="${pageContext.request.contextPath}/sbgl/getAll">
                <input type="hidden" name="currentPageNo" value="1" />
                <ul>
                    <li>
                        <div class="form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">设备名称</label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <input name="shebeiName" type="text" class="form-control col-md-7 col-xs-12" value="${shebeiName}">
                            </div>
                        </div>
                    </li>

                    <li>
                        <div class="form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">设备状态</label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <select name="zhuangtai" class="form-control">
                                    <option value="" selected>--请选择--</option>
                                    <c:set var="sbzt" value="${sheBeiKuCunList}"></c:set>
                                        <option value="0" <c:if test="${zhuangtai=='0'}">selected</c:if>>正常</option>
                                        <option value="1" <c:if test="${zhuangtai=='1'}">selected</c:if>>维修</option>
                                        <option value="2" <c:if test="${zhuangtai=='2'}">selected</c:if>>报废</option>
                                </select>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="form-group">
                            <label class="control-label col-md-3 col-sm-3 col-xs-12">所属科室</label>
                            <div class="col-md-6 col-sm-6 col-xs-12">
                                <select name="keshiId" class="form-control">
                                    <option value="0" selected>--请选择--</option>
                                    <c:forEach var="Keshi" items="${keShiService}">
                                        <option value="${Keshi.kid}" <c:if test="${keshiId == Keshi.kid}">selected</c:if>>${Keshi.kname}</option>
                                    </c:forEach>

                                </select>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="form-group">
                            <%--<label class="control-label col-md-3 col-sm-3 col-xs-12">一级分类</label>--%>
                            <%--<div class="col-md-6 col-sm-6 col-xs-12">--%>
                                <%--<select id="queryCategoryLevel1" name="queryCategoryLevel1" class="form-control">--%>
                                    <%--<option value="0">--请选择--</option>--%>
                                    <%--<c:forEach var="appCategory" items="${appCategory1List}">--%>
                                        <%--<option <c:if test="${queryCategoryLevel1 eq appCategory.id}">selected="selected"</c:if>--%>
                                                <%--value="${appCategory.id}">${appCategory.categoryName}</option>--%>
                                    <%--</c:forEach>--%>
                                <%--</select>--%>
                            <%--</div>--%>
                        </div>
                    </li>
                    <li>
                        <div class="form-group">
                            <%--<label class="control-label col-md-3 col-sm-3 col-xs-12">二级分类</label>--%>
                            <%--<div class="col-md-6 col-sm-6 col-xs-12">--%>
                                <%--<input type="hidden" name="categorylevel2" id="categorylevel2list"/>--%>
                                <%--<select name="queryCategoryLevel2" id="queryCategoryLevel2" class="form-control">--%>

                                    <%--<option value="0">--请选择--</option>--%>
                                    <%--<c:forEach var="appCategory" items="${appCategory2List}">--%>
                                        <%--<option <c:if test="${queryCategoryLevel2 eq appCategory.id}">selected="selected"</c:if>--%>
                                                <%--value="${appCategory.id}">${appCategory.categoryName}</option>--%>
                                    <%--</c:forEach>--%>
                                <%--</select>--%>
                            <%--</div>--%>
                        </div>
                    </li>
                    <li>
                        <div class="form-group">
                            <%--<label class="control-label col-md-3 col-sm-3 col-xs-12">三级分类</label>--%>
                            <%--<div class="col-md-6 col-sm-6 col-xs-12">--%>
                                <%--<select name="queryCategoryLevel3" id="queryCategoryLevel3" class="form-control">--%>
                                    <%--<option value="0">--请选择--</option>--%>
                                    <%--<c:forEach var="appCategory" items="${appCategory3List}">--%>
                                        <%--<option <c:if test="${queryCategoryLevel3 eq appCategory.id}">selected="selected"</c:if>--%>
                                                <%--value="${appCategory.id}">${appCategory.categoryName}</option>--%>
                                    <%--</c:forEach>--%>
                                <%--</select>--%>
                            <%--</div>--%>
                        </div>
                    </li>
                    <li><button type="submit" class="btn btn-primary"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询 </button></li>
                </ul>
                    <div class="layui-form x-center layui-form-pane" style="width:500px">
                        <div class="layui-form-item">
                            <div class="layui-input-inline" style="width:400px">
                                <input type="text" name="mohuName" value="${mohuName}" placeholder="搜索内容" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline" style="width:80px">
                                <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </div>
                    </div>
            </form>
        </div>

        <div class="x-body">
        <%--<form class="layui-form x-center" action="${pageContext.request.contextPath}/sbgl/getAll" style="width:500px">--%>

            <%--</form>--%>
    <div class="tools">
        <ul class="toolbar">
          <li id="delBatch"><span><img src="../images/t03.png" /></span>批量删除</li>
          <%--<li onclick="home_add('添加用户','/jsp/home_add.html','600','500')"><span><img src="../images/t01.png" /></span>添加</li>--%>
          <li onclick="sbgl_add('添加用户','/sbgl/goAdd','600','500')"><span><img src="../images/t01.png" /></span>添加</li>
          <%--<li><span><img src="../images/t08.png"></span>审核</li>--%>
        </ul>
        <span class="x-right" style="line-height:25px">共有数据:${totalCount}条</span></xblock>
        <span class="x-right" style="line-height:25px" align="left">第${currentPageNo}页/共${totalPageCount}页</span>
    </div>
            <table class="tablelist">
                <thead>
                    <tr>
                        <th width="4%">
                            <input onclick="selectAll()" type="checkbox"   name="controlAll" style="" id="controlAll">
                        </th>
                        <th width="4%">序号</th>
                        <th width="8%">设备名称</th>
                        <th width="10%">设备编号</th>
                        <th width="8%">设备型号</th>
                        <th width="8%">产品类型</th>
                        <th width="4%">数量</th>
                        <th width="20%">简介</th>
                        <th width="7%">入库时间</th>
                        <th width="7%">出库时间</th>
                        <th width="6%">显示状态</th>
                        <th width="6%">科室</th>
                        <th width="8%">操作</th>

                    </tr>
                    <c:forEach var="SheBeiKuCun" items="${sheBeiKuCunList}" varStatus="row">
                        <tr >
                            <td width="4%">
                                <input onclick="selectAll()" type="checkbox"  value="${SheBeiKuCun.sId}" name="controlAll" style="controlAll" id="controlAll">
                            </td>
                            <td>${SheBeiKuCun.sId}</td>
                            <td>${SheBeiKuCun.xzId}</td>
                            <td>${SheBeiKuCun.sbCode}</td>
                            <td>${SheBeiKuCun.sbType}</td>
                            <td>${SheBeiKuCun.cpType}</td>
                            <td>${SheBeiKuCun.sbNumber}</td>
                            <td>${SheBeiKuCun.cpUse}</td>
                            <td>
                                <fmt:formatDate value="${SheBeiKuCun.rukuTime}" pattern="yyyy-MM-dd"/>
                            </td>
                            <td>
                                <fmt:formatDate value="${SheBeiKuCun.chukuTime}" pattern="yyyy-MM-dd"/>
                            </td>
                            <td>
                                <c:if test="${SheBeiKuCun.zt eq 0}">正常</c:if>
                                <c:if test="${SheBeiKuCun.zt eq 1}">维修</c:if>
                                <c:if test="${SheBeiKuCun.zt eq 2}">报废</c:if>
                            </td>
                            <td>
                                    ${SheBeiKuCun.kName}
                            </td>
                            <td class="td-manage">
                                <a style="text-decoration:none" onclick="chakan(${SheBeiKuCun.sId})" href="javascript:;" title="查看">
                                    <i class="layui-icon"></i>
                                </a>
                                <%--<a style="text-decoration:none" href="${pageContext.request.contextPath}/sbgl/seesbkc?sId=${SheBeiKuCun.sId}" title="查看">--%>
                                    <%--<i class="layui-icon"></i>--%>
                                <%--</a>--%>
                                <%--<a title="修改" href="javascript:;" onclick="home_edit('修改','/jsp/home_edit.html','4','','510')"--%>
                                <a title="修改" href="javascript:;" onclick="sbgl_edit('修改','/sbgl/goUpdate?sId=${SheBeiKuCun.sId}','4','','510')"
                                   class="ml-5" style="text-decoration:none">
                                    <i class="layui-icon">&#xe642;</i>
                                </a>
                                <a title="删除" href="javascript:;" onclick="banner_del(${SheBeiKuCun.sId})"
                                   style="text-decoration:none">
                                    <i class="layui-icon" >&#xe640;</i>
                                </a>
                            </td>
                        </tr>
                    </c:forEach>
                </thead>
                <tbody id="x-img">


                </tbody>
            </table>
<%--<div class="page"  v-show="show">--%>
  <%--<div class="pagelist"> <span class="jump">上一页</span> <span class="jump">1</span> <span class="jump">2</span> <span class="jump">3</span> <span class="jump">4</span> <span class="jump">5</span> <span class="jump">6</span> <span class="ellipsis">...</span> <span class="jump">下一页</span> <span class="jumppoint">跳转到：</span> <span class="jumpinp">--%>
    <%--<input type="text">--%>
    <%--</span> <span class="jump gobtn">GO</span> </div>--%>
<%--</div>--%>

    <div class="page" v-show="show">
        <div class="pagelist">
            <input type="hidden" id="totalPageCount" value="${totalPageCount}">
            <c:if test="${currentPageNo>1}">
                <span class="jump"><a href="javascript:page_nav(document.forms[0],1);">首页</a></span>
                <span class="jump"><a href="javascript:page_nav(document.forms[0],${currentPageNo - 1});">上一页</a></span>
            </c:if>
            <c:if test="${currentPageNo<totalPageCount}">
                <span class="jump"><a href="javascript:page_nav(document.forms[0],${currentPageNo + 1});">下一页</a></span>
                <span class="jump"><a href="javascript:page_nav(document.forms[0],${totalPageCount});">尾页</a></span>
            </c:if>
            <span class="jumppoint">跳转到：</span>
            <span class="jumpinp"><input type="text" name="inputPage" id="inputPage" value=""></span>
            <button type="button" class="jump gobtn" onclick="jump_to(document.forms[0],document.getElementById('inputPage').value)">GO</button>

        </div>
        <div>
            <div id="page_container">
            </div>
        </div>
    </div>
</div>

<br />
<br />
<br />
        <script src="../lib/layui/layui.js" charset="utf-8"></script>
        <script src="../js/x-layui.js" charset="utf-8"></script>
<script src="../js/jquery2.js" charset="utf-8"></script>
        <script src="../js/sbgl/rollpage.js"></script>
<script src="../js/js.js" charset="utf-8"></script>
        <script>
            layui.use(['laydate','element','laypage','layer'], function(){
                $ = layui.jquery;//jquery
              laydate = layui.laydate;//日期插件
              lement = layui.element;//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层
            });

             /*添加*/
            // function home_add(title,url,w,h){
            //     x_admin_show(title,url,w,h);
            // }
            /*添加*/
            function sbgl_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }

            // 编辑
            // function home_edit (title,url,id,w,h) {
            function sbgl_edit (title,url,id,w,h) {
                x_admin_show(title,url,w,h);
            }
			$('.tablelist tbody tr:odd').addClass('odd');

            //单个删除设备
          function banner_del(sId) {
              var tips =confirm("是否确认删除");//弹出确认框，点击是则tips为true  否则为false;
              if(tips) {//如果点击确认  进行if里的操作(确认删除)
                  $.ajax({
                      type: "get",
                      url: "/sbgl/del/" + sId,
                      dataType: "json",
                      success: function (data) {
                          var flag = data.retMsg;
                          if (flag) {
                              // layer.msg("删除成功");
                              layer.open({
                                  title: '信息',
                                  content: '删除成功',
                                  end: function () {
                                      location.reload();
                                  }
                              });
                          } else {
                              layer.msg("删除失败");
                          }
                      },
                      error: function () {
                          layer.msg("删除异常");
                      }
                  })
              }else{
                  return false;//如果取消  则返回false
              }
            }
            //批量删除
            $("#delBatch").bind("click",function () {
                var tips =confirm("是否确认删除");//弹出确认框，点击是则tips为true  否则为false;
                if(tips){//如果点击确认  进行if里的操作(确认删除)
                    var x = $("input[name='controlAll']");//获取所有的checkbox
                    var list = new Array();//构造传入后台的数据。
                    for(var i = 0;i<x.length;i++){//遍历所有checkbox
                        if(x[i].checked){//检查每个box是否选中
                            list.push(parseInt(x[i].value));//选中的将box的value push进入list
                        }
                    }
                    if(list.length>0){//如果list的长度大于0  不为空  则进行ajax校验
                        $.ajax({
                            url:"${pageContext.request.contextPath}/sbgl/delBatch",//后台url
                            type:"post",//后台进行接收的方法
                            dataType:"json",//前台接收的数据格式
                            data:{"delList":JSON.stringify(list)},//传入的数据，json格式   {"delList":[1,2,3]}  key 为 string   value 为 数组
                            success:function (data) {
                                if(data.msg=="success"){//如果后台返回的json的msg为success
                                    layer.open({//弹出提示框，
                                        title:"提示",//标题
                                        content:"删除成功",//内容
                                        end:function () {//弹框消失后的回调函数
                                            location.reload();//刷新页面
                                        }
                                    });
                                }else if(data.msg == "failed"){//后台返回的msg为failed   删除失败的操作
                                    layer.open({
                                        title:"提示",
                                        content:"删除失败",
                                        end:function () {
                                            location.reload();
                                        }
                                    });
                                }else{
                                    console.log(data);//不可能事件
                                }
                            },error:function (e) {//ajax的失败回调
                                console.log(e)//打印e
                            }
                        })
                    }else{
                        layer.msg("请选择序号！",{icon:2})
                        return false;//如果未选择box  则返回false
                    }
                }else{
                    return false;//如果取消  则返回false
                }
            })
            //设备详情
            function chakan(sId) {
                layer.open({
                    type: 2,
                    area: ['850px', '850px'],
                    fix: false, //不固定
                    maxmin: true,
                    shadeClose: true,
                    shade: 0.4,
                    title: '设备详情信息',
                    content: '/sbgl/seesbkc?sId=' + sId,
                    end:function () {
                        //window.location.reload();//刷新本页面

                    }
                });
            }
            </script>
    </body>
</html>